package com.liangsong.designpattern.singleton;

/**
 * @author liangsong
 * @version 1.0 2025/1/9
 * 饿汉模式，在类刚一初始化的时候就立即把单例对象创建出来,下面两种都是饿汉模式的实现。
 * */

public class HungrySingleton {

    private static final HungrySingleton instance;

    static {
        instance = new HungrySingleton();
    }

    private HungrySingleton(){

    }

    public static HungrySingleton getInstance(){
        return instance;
    }

    public void test(){
        System.out.println(this.getClass().getName());
    }

}
